package com.servlet;

import com.entity.Students;
import com.tools.Utils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Update {
    public boolean update(Students students){
        //详见Insert
        Connection con=Utils.getConn();
        String sql="UPDATE students SET sname=?,sage=?,sclass=? WHERE sid=?;";
        try {
            PreparedStatement pstate=con.prepareStatement(sql);
            pstate.setString(1,students.getSname());
            pstate.setString(2,students.getSage());
            pstate.setString(3,students.getSclass());
            pstate.setInt(4,students.getSid());
            pstate.execute();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return true;
    }
}
